<template>
  <div class="dataComfigure">
    <MetaSearchForm @on-search="tableSearch">
      <el-form
        ref="dataManagement_form"
        :model="modelSearch"
        class="dataConfigure_searchForm"
      >
        <el-form-item
          label="设备"
          class="dataConfigure_searchFormItem"
          label-width="80px"
        >
          <el-select
            v-model="modelSearch.equipmentId"
            placeholder="请选择设备"
            filterable
            clearable
          >
            <el-option
              v-for="item in equipmentList"
              :key="item.id"
              :label="item.equipmentName"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="手动构建类型"
          class="dataConfigure_searchFormItem"
          label-width="150px"
        >
          <el-select
            v-model="modelSearch.modelType"
            placeholder="请选择优化类型"
            filterable
            clearable
          >
            <el-option
              v-for="item in modelTypeList"
              :key="item.id"
              :label="item.value"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item
          label="模型构建时间"
          class="dataConfigure_searchFormItem"
          label-width="150px"
        >
          <el-date-picker
            v-model="modelSearch.dateBetween"
            type="daterange"
            range-separator="-"
            value-format="yyyy-MM-dd"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>
    </MetaSearchForm>
    <MetaPageTable
      ref="dataConfigureTable"
      class="dataConfigure_table"
      table-title="手动构建模型列表"
      :is-auto-req="true"
      :req-url="reqUrl"
      :req-data="modelSearch"
      req-method="post"
      :display-item="displayItem"
      :btn-group="btnGroup"
      @btnClick="tableBtnClick"
      :line-btn-group="lineBtnGroup"
      @lineBtnClick="tableInlineBtnClick"
    />
    <el-dialog
      :visible.sync="newModelDialog"
      v-if="newModelDialog"
      width="80%"
      modal
      center
      :close-on-click-modal="false"
      :title="modelData.id && modelData.id !== '' ? '模型迭代' : '手动构建模型'"
      :before-close="cancelConfigure"
    >
      <div>
        <el-form
          :model="modelData"
          label-width="170px"
          ref="modelDataForm"
          :rules="modelDataRules"
        >
          <el-form-item label="Equipment Selection" prop="equipmentId">
            <el-select
              v-model="modelData.equipmentId"
              placeholder="请选择设备"
              clearable
              filterable
              style="width: 80%"
              @change="showEquipmentName"
              :disabled="modelData.id && modelData.id !== '' ? true : false"
            >
              <el-option
                v-for="item in equipmentList"
                :key="item.id"
                :label="item.equipmentName"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item
            label="Water_Para"
            prop="waterParameters"
            v-if="!(modelData.id && modelData.id !== '')"
          >
            <el-select
              v-model="modelData.waterParameters"
              placeholder="请选择参数"
              multiple
              clearable
              style="width: 80%"
              @change="selectParam($event)"
            >
              <el-option
                v-for="item in paramsList"
                :key="item.paramkey"
                :label="item.paramname"
                :value="item.paramkey"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="Water_Para" v-if="modelData.id && modelData.id !== ''">
            <el-input v-model="modelIteration" style="width: 80%" disabled> </el-input>
          </el-form-item>
          <el-form-item label="Param_Model">
            <div class="bandTitle">
              <el-tabs v-model="paramChooseItem" @tab-click="handleClick">
                <el-tab-pane
                  v-for="item in buildDetails"
                  :key="item.key"
                  :label="item.label"
                  :name="item.label"
                >
                  <div class="bandTable" style="max-height: 400px; overflow: auto">
                    <div
                      class="bandTableItem"
                      v-if="!(modelData.id && modelData.id !== '')"
                    >
                      <div class="bandTableItem_conLabel">Model Selection</div>
                      <div class="bandTableItem_con">
                        <el-form-item class="bandTableItem_input">
                          <el-radio
                            v-model="item.methodType"
                            v-for="(methodItem, index) in methodType_list"
                            :label="methodItem.value"
                            @change="showMethods"
                            @input="change($event)"
                            :key="index"
                            >{{ methodItem.name }}</el-radio
                          >
                        </el-form-item>
                      </div>
                    </div>
                    <div class="bandTableItem" v-if="modelData.id && modelData.id !== ''">
                      <div class="bandTableItem_conLabel">Model Selection</div>
                      <div class="bandTableItem_con">
                        <el-form-item class="bandTableItem_input">
                          <el-radio
                            v-model="item.methodType"
                            v-for="(methodItem, index) in methodType_list"
                            :label="methodItem.value"
                            :key="index"
                            disabled
                            >{{ methodItem.name }}</el-radio
                          >
                        </el-form-item>
                      </div>
                    </div>
                    <!-- 不同方法的不同传参 -->
                    <!-- 随机组合传参形式 -->
                    <div v-if="item.RandomFlag">
                      <div class="randomTable">
                        <div class="randomTableData">
                          <el-form
                            :model="randomNum"
                            style="width: 100%"
                            class="randomInputForm"
                          >
                            <el-form-item class="randomInputFormContent">
                              <div class="randomInputItem">
                                <div style="width: 40px">L:</div>
                                <el-input
                                  v-model="item.lower"
                                  @input="change($event)"
                                ></el-input>
                              </div>
                              <div class="randomInputItem">
                                <div style="width: 40px">U:</div>
                                <el-input
                                  v-model="item.upper"
                                  @input="change($event)"
                                ></el-input>
                              </div>
                            </el-form-item>
                          </el-form>
                        </div>
                      </div>
                    </div>
                    <!-- 波段组合参数详情 -->

                    <div v-if="item.BandFlag">
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Pre-process</div>
                        <div class="bandTableItem_con">
                          <el-form-item label="Band_del" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Head:</div>
                              <el-input
                                v-model="item.bandDelete.startIndex"
                                type="number"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Tail:</div>
                              <el-input
                                v-model="item.bandDelete.endIndex"
                                type="number"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                          <div style="color:#b2b2b2;margin:0 3%">Tips：波段范围为0~302</div>
                          <el-form-item label="SG filtering" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">W:</div>
                              <el-input
                                v-model="item.deNoise.w"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">K:</div>
                              <el-input
                                v-model="item.deNoise.k"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                          <el-form-item label="Ref-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.informEnhance"
                              v-for="(refItem, index) in ref_process_list"
                              :label="refItem.value"
                              @input="change($event)"
                              :key="index"
                              >{{ refItem.name }}</el-radio
                            >
                          </el-form-item>
                        </div>
                      </div>
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Model</div>
                        <div class="bandTableItem_conBand">
                          <div class="bandTableItem_conBand_con">
                            <div class="bandTableItem_conBandItemLeft">
                              <el-form-item label="Band_Combine_Math" label-width="250px">
                                <el-radio
                                  v-model="item.bandCombineMath.method"
                                  label="DValue"
                                  @input="change($event)"
                                  >差</el-radio
                                >
                                <el-radio
                                  v-model="item.bandCombineMath.method"
                                  label="ratio"
                                  @input="change($event)"
                                  >比</el-radio
                                >
                                <el-radio
                                  v-model="item.bandCombineMath.method"
                                  label="diffSumRatio"
                                  @input="change($event)"
                                  >差/和</el-radio
                                >
                              </el-form-item>
                            </div>
                            <div class="bandTableItem_conBandItemRight">
                              <el-form-item
                                label="Central wavelength:"
                                label-width="200px"
                              >
                                <el-input
                                  v-model="item.bandCombineMath.featureBand"
                                  @input="change($event)"
                                ></el-input>
                              </el-form-item>
                              <el-form-item label="Model_Para:" label-width="200px">
                                <el-input
                                  v-model="item.bandCombineMath.modelPara"
                                  @input="change($event)"
                                ></el-input>
                              </el-form-item>
                            </div>
                          </div>
                          <div style="color:#b2b2b2">Tips：a*x+b</div>
                        </div>
                      </div>
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Water_Para Range</div>
                        <div class="bandTableItem_con">
                          <el-form-item label="" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">L:</div>
                              <el-input
                                v-model="item.paramRange.lower"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">U:</div>
                              <el-input
                                v-model="item.paramRange.upper"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                        </div>
                      </div>
                      <!-- 模型修正 -->
                      <div
                        class="bandTableItem"
                        v-if="modelData.id && modelData.id !== '' ? true : false"
                      >
                        <div class="bandTableItem_conLabel">Result Modify</div>
                        <div class="bandTableItem_con">
                          <el-form-item class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Coef:</div>
                              <el-input
                                v-model="item.resultCorrect.coef"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Inter:</div>
                              <el-input
                                v-model="item.resultCorrect.inter"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                        </div>
                      </div>
                    </div>
                    <!-- 多项式组合参数详情 -->

                    <div v-if="item.PolyFlag">
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Pre-process</div>
                        <div class="bandTableItem_con">
                          <el-form-item label="Band_del" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Head:</div>
                              <el-input
                                v-model="item.bandDelete.startIndex"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Tail:</div>
                              <el-input
                                v-model="item.bandDelete.endIndex"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                          <el-form-item label="SG filtering" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">W:</div>
                              <el-input
                                v-model="item.deNoise.w"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">K:</div>
                              <el-input
                                v-model="item.deNoise.k"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                          <el-form-item label="Ref-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.informEnhance"
                              v-for="(refItem, index) in ref_process_list"
                              :label="refItem.value"
                              @input="change($event)"
                              :key="index"
                              >{{ refItem.name }}</el-radio
                            >
                          </el-form-item>
                        </div>
                      </div>
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Model</div>
                        <div class="bandTableItem_conBand">
                          <div class="bandTableItem_conBandItem">
                            <el-form-item label="Central wavelength:">
                              <el-input
                                v-model="item.polynomialBandMath.featureBand"
                                @input="change($event)"
                              ></el-input>
                            </el-form-item>
                            <el-form-item label="Model_Para:">
                              <!-- <div style="width: 35%; margin-left: 20px">Model_Para:</div> -->
                              <el-input
                                v-model="item.polynomialBandMath.modelPara"
                                @input="change($event)"
                              ></el-input>
                            </el-form-item>
                          </div>
                          <div style="color:#b2b2b2">
                            Tips：b+a0*x<sub>0</sub>+a1*x<sub>1</sub>+...+an*x<sub>n</sub>
                          </div>
                        </div>
                      </div>
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Water_Para Range</div>
                        <div class="bandTableItem_con">
                          <el-form-item label="" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">L:</div>
                              <el-input
                                v-model="item.paramRange.lower"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">U:</div>
                              <el-input
                                v-model="item.paramRange.upper"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                        </div>
                      </div>
                      <!-- 模型修正 -->
                      <div
                        class="bandTableItem"
                        v-if="modelData.id && modelData.id !== '' ? true : false"
                      >
                        <div class="bandTableItem_conLabel">Result Modify</div>
                        <div class="bandTableItem_con">
                          <el-form-item class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Coef:</div>
                              <el-input
                                v-model="item.resultCorrect.coef"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Inter:</div>
                              <el-input
                                v-model="item.resultCorrect.inter"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                        </div>
                      </div>
                    </div>
                    <!-- TDS参数详情 -->
                    <div v-if="item.TdsFlag">
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Pre-process</div>
                        <div class="bandTableItem_con">
                          <el-form-item label="Band_del" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Head:</div>
                              <el-input
                                v-model="item.bandDelete.startIndex"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Tail:</div>
                              <el-input
                                v-model="item.bandDelete.endIndex"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                          <el-form-item label="SG filtering" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">W:</div>
                              <el-input
                                v-model="item.deNoise.w"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">K:</div>
                              <el-input
                                v-model="item.deNoise.k"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                          <el-form-item label="Ref-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.informEnhance"
                              v-for="(refItem, index) in ref_process_list"
                              :label="refItem.value"
                              @input="change($event)"
                              :key="index"
                              >{{ refItem.name }}</el-radio
                            >
                          </el-form-item>
                          <el-form-item label="T-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.tProcess"
                              label="R"
                              @change="chooseT"
                              @input="change($event)"
                              >R</el-radio
                            ><el-radio
                              v-model="item.tProcess"
                              label="recip"
                              @change="chooseT"
                              @input="change($event)"
                              >RE</el-radio
                            ><el-radio
                              v-model="item.tProcess"
                              label="exp"
                              @change="chooseT"
                              @input="change($event)"
                              >EXP</el-radio
                            >

                            <el-radio
                              v-model="item.tProcess"
                              label="ln"
                              @change="chooseT"
                              @input="change($event)"
                              >LN</el-radio
                            >
                          </el-form-item>
                          <el-form-item label="TDS-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.tdsProcess"
                              label="R"
                              @change="chooseTds"
                              @input="change($event)"
                              >R</el-radio
                            ><el-radio
                              v-model="item.tdsProcess"
                              label="recip"
                              @change="chooseTds"
                              @input="change($event)"
                              >RE</el-radio
                            ><el-radio
                              v-model="item.tdsProcess"
                              label="exp"
                              @change="chooseTds"
                              @input="change($event)"
                              >EXP</el-radio
                            >
                            <el-radio
                              v-model="item.tdsProcess"
                              label="ln"
                              @change="chooseTds"
                              @input="change($event)"
                              >LN</el-radio
                            >
                          </el-form-item>
                        </div>
                      </div>
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Model</div>
                        <div class="bandTableItem_conBand">
                          <div
                            class="bandTableItem_conBandItem"
                            style="display: flex; flex-direction: column"
                          >
                            <div class="bandTableItem_conBandItem_tds">
                              <el-form-item
                                label-width="180px"
                                label="Central wavelength:"
                              >
                                <el-input
                                  v-model="item.tdsBandMath.central_wavelength"
                                  @input="change($event)"
                                ></el-input>
                              </el-form-item>
                              <el-form-item label-width="180px" label="Wave_Model_Para:">
                                <el-input
                                  v-model="item.tdsBandMath.wave_modelPara"
                                  @input="change($event)"
                                ></el-input>
                              </el-form-item>
                            </div>
                            <div class="bandTableItem_tips" style="color:#b2b2b2">
                              Tips：b+a0*x<sub>0</sub>+a1*x<sub>1</sub>+...+an*x<sub
                                >n</sub
                              >
                            </div>
                            <div class="bandTableItem_conBandItem_tds">
                              <el-form-item label-width="180px" label="T_Model_Para:">
                                <el-input
                                  v-model="item.tdsBandMath.T_modelPara"
                                  @input="change($event)"
                                ></el-input>
                              </el-form-item>
                              <el-form-item label-width="180px" label=" TDS_Model_Para:">
                                <el-input
                                  v-model="item.tdsBandMath.TDS_modelPara"
                                  @input="change($event)"
                                ></el-input>
                              </el-form-item>
                            </div>
                            <div class="bandTableItem_tips" style="color:#b2b2b2">Tips：a*x+b</div>
                          </div>
                        </div>
                      </div>
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Water_Para Range</div>
                        <div class="bandTableItem_con">
                          <el-form-item label="" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">L:</div>
                              <el-input
                                v-model="item.paramRange.lower"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">U:</div>
                              <el-input
                                v-model="item.paramRange.upper"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                        </div>
                      </div>
                      <!-- 模型修正 -->
                      <div
                        class="bandTableItem"
                        v-if="modelData.id && modelData.id !== '' ? true : false"
                      >
                        <div class="bandTableItem_conLabel">Result Modify</div>
                        <div class="bandTableItem_con">
                          <el-form-item class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Coef:</div>
                              <el-input
                                v-model="item.resultCorrect.coef"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Inter:</div>
                              <el-input
                                v-model="item.resultCorrect.inter"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                        </div>
                      </div>
                    </div>

                    <!-- Poly_F参数详情 -->
                    <div v-if="item.Poly_FFlag">
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Pre-process</div>
                        <div class="bandTableItem_con">
                          <el-form-item label="Band_del" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Head:</div>
                              <el-input
                                v-model="item.bandDelete.startIndex"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Tail:</div>
                              <el-input
                                v-model="item.bandDelete.endIndex"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                          <el-form-item label="SG filtering" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">W:</div>
                              <el-input
                                v-model="item.deNoise.w"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">K:</div>
                              <el-input
                                v-model="item.deNoise.k"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                          <el-form-item label="Ref-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.informEnhance"
                              v-for="(refItem, index) in ref_process_list"
                              :label="refItem.value"
                              @input="change($event)"
                              :key="index"
                              >{{ refItem.name }}</el-radio
                            >
                          </el-form-item>
                          <el-form-item label="T-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.tProcess"
                              label="R"
                              @change="chooseT"
                              @input="change($event)"
                              >R</el-radio
                            ><el-radio
                              v-model="item.tProcess"
                              label="recip"
                              @change="chooseT"
                              @input="change($event)"
                              >RE</el-radio
                            ><el-radio
                              v-model="item.tProcess"
                              label="expx"
                              @change="chooseT"
                              @input="change($event)"
                              >EXP</el-radio
                            >
                            <el-input
                              v-model="item.tPreCoef"
                              v-if="isTPreCoef"
                              style="width: 150px; margin-right: 20px"
                            ></el-input
                            ><el-radio
                              v-model="item.tProcess"
                              label="ln"
                              @change="chooseT"
                              @input="change($event)"
                              >LN</el-radio
                            >
                          </el-form-item>
                          <el-form-item label="TDS-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.tdsProcess"
                              label="R"
                              @change="chooseTds"
                              @input="change($event)"
                              >R</el-radio
                            ><el-radio
                              v-model="item.tdsProcess"
                              label="recip"
                              @change="chooseTds"
                              @input="change($event)"
                              >RE</el-radio
                            ><el-radio
                              v-model="item.tdsProcess"
                              label="expx"
                              @change="chooseTds"
                              @input="change($event)"
                              >EXP</el-radio
                            >
                            <el-input
                              v-model="item.tdsPreCoef"
                              v-if="isTdsPreCoef"
                              style="width: 150px; margin-right: 20px"
                            ></el-input
                            ><el-radio
                              v-model="item.tdsProcess"
                              label="ln"
                              @change="chooseTds"
                              @input="change($event)"
                              >LN</el-radio
                            >
                          </el-form-item>
                        </div>
                      </div>
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Model</div>
                        <div class="bandTableItem_conBand">
                          <div
                            class="bandTableItem_conBandItem"
                            style="display: flex; flex-direction: column"
                          >
                            <div class="bandTableItem_conBandItem_tds">
                              <el-form-item
                                label-width="180px"
                                label="Central wavelength:"
                              >
                                <el-input
                                  v-model="item.tdsBandMath.central_wavelength"
                                  @input="change($event)"
                                ></el-input>
                              </el-form-item>
                              <el-form-item label-width="180px" label="Wave_Model_Para:">
                                <el-input
                                  v-model="item.tdsBandMath.wave_modelPara"
                                  @input="change($event)"
                                ></el-input>
                              </el-form-item>
                            </div>
                            <div class="bandTableItem_tips" >
                              Tips：b+a0*x<sub>0</sub>+a1*x<sub>1</sub>+...+an*x<sub
                                >n</sub
                              >
                            </div>
                            <div class="bandTableItem_conBandItem_tds">
                              <el-form-item label-width="180px" label="T_Model_Para:">
                                <el-input
                                  v-model="item.tdsBandMath.T_modelPara"
                                  @input="change($event)"
                                ></el-input>
                              </el-form-item>
                              <el-form-item label-width="180px" label=" TDS_Model_Para:">
                                <el-input
                                  v-model="item.tdsBandMath.TDS_modelPara"
                                  @input="change($event)"
                                ></el-input>
                              </el-form-item>
                            </div>
                            <div class="bandTableItem_tips">
                              Tips：b+a0*x+a1*x<sup>2</sup>+...+an*x<sup>n</sup>
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Water_Para Range</div>
                        <div class="bandTableItem_con">
                          <el-form-item label="" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">L:</div>
                              <el-input
                                v-model="item.paramRange.lower"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">U:</div>
                              <el-input
                                v-model="item.paramRange.upper"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                        </div>
                      </div>
                      <!-- 模型修正 -->
                      <div
                        class="bandTableItem"
                        v-if="modelData.id && modelData.id !== '' ? true : false"
                      >
                        <div class="bandTableItem_conLabel">Result Modify</div>
                        <div class="bandTableItem_con">
                          <el-form-item class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Coef:</div>
                              <el-input
                                v-model="item.resultCorrect.coef"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Inter:</div>
                              <el-input
                                v-model="item.resultCorrect.inter"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                        </div>
                      </div>
                    </div>

                    <!-- RF参数详情 -->
                    <div v-if="item.RFFlag">
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Pre-process</div>
                        <div class="bandTableItem_con">
                          <el-form-item label="Band_del" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Head:</div>
                              <el-input
                                v-model="item.bandDelete.startIndex"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Tail:</div>
                              <el-input
                                v-model="item.bandDelete.endIndex"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                          <el-form-item label="SG filtering" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">W:</div>
                              <el-input
                                v-model="item.deNoise.w"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">K:</div>
                              <el-input
                                v-model="item.deNoise.k"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                          <el-form-item label="Ref-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.informEnhance"
                              v-for="(refItem, index) in ref_process_list"
                              :label="refItem.value"
                              @input="change($event)"
                              :key="index"
                              >{{ refItem.name }}</el-radio
                            >
                          </el-form-item>
                          <el-form-item label="T-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.tProcess"
                              label="No"
                              @change="chooseT"
                              @input="change($event)"
                              >No</el-radio
                            >
                            <el-radio
                              v-model="item.tProcess"
                              label="R"
                              @change="chooseT"
                              @input="change($event)"
                              >R</el-radio
                            ><el-radio
                              v-model="item.tProcess"
                              label="recip"
                              @change="chooseT"
                              @input="change($event)"
                              >RE</el-radio
                            ><el-radio
                              v-model="item.tProcess"
                              label="expx"
                              @change="chooseT"
                              @input="change($event)"
                              >EXP</el-radio
                            >
                            <el-input
                              v-model="item.tPreCoef"
                              v-if="isTPreCoef"
                              style="width: 150px; margin-right: 20px"
                            ></el-input
                            ><el-radio
                              v-model="item.tProcess"
                              label="ln"
                              @change="chooseT"
                              @input="change($event)"
                              >LN</el-radio
                            >
                          </el-form-item>
                          <el-form-item label="TDS-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.tdsProcess"
                              label="No"
                              @change="chooseT"
                              @input="change($event)"
                              >No</el-radio
                            >
                            <el-radio
                              v-model="item.tdsProcess"
                              label="R"
                              @change="chooseTds"
                              @input="change($event)"
                              >R</el-radio
                            ><el-radio
                              v-model="item.tdsProcess"
                              label="recip"
                              @change="chooseTds"
                              @input="change($event)"
                              >RE</el-radio
                            ><el-radio
                              v-model="item.tdsProcess"
                              label="expx"
                              @change="chooseTds"
                              @input="change($event)"
                              >EXP</el-radio
                            >
                            <el-input
                              v-model="item.tdsPreCoef"
                              v-if="isTdsPreCoef "
                              style="width: 150px; margin-right: 20px"
                            ></el-input
                            ><el-radio
                              v-model="item.tdsProcess"
                              label="ln"
                              @change="chooseTds"
                              @input="change($event)"
                              >LN</el-radio
                            >
                          </el-form-item>
                        </div>
                      </div>
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Model</div>
                        <div class="bandTableItem_conBand">
                          <div
                            class="bandTableItem_conBandItem"
                            style="display: flex; flex-direction: column"
                          >
                            <div
                              class="bandTableItem_conBandItem_rf"
                              style="width: 100%"
                            >
                              <el-form-item
                                label-width="180px"
                                label="Central wavelength:"
                              >
                                <el-radio
                                  v-model="item.rfBandMath.waveType"
                                  label="All_wave"
                                  @change="chooseWave"
                                  @input="change($event)"
                                  >All_wave</el-radio
                                ><el-radio
                                  v-model="item.rfBandMath.waveType"
                                  label="Sel_wave"
                                  @change="chooseWave"
                                  @input="change($event)"
                                  >Sel_wave</el-radio
                                >
                                <el-input
                                  v-model="item.rfBandMath.central_wavelength"
                                  v-if="isSel_wave"
                                  placeholder="不可为空"
                                  style="width: 150px; margin-right: 20px"
                                ></el-input
                                >
                              </el-form-item>
                              <el-form-item
                                label-width="180px"
                                label="Model:"
                              >
                               <el-upload
                                  class="upload-demo"
                                  :action="rfuploadUrl"
                                  :headers="{
                                    'x-auth-token': token,
                                  }"
                                  :disabled="modelData.id && modelData.id !== '' ? true : false"
                                  :before-upload="rfBeforeUpload"
                                  :on-success="rfHandleSuccess"
                                  :limit="1"
                                  :file-list="rfFileList"
                                >
                                  <el-button size="small" type="primary"
                                    >点击上传</el-button
                                  >
                                  <div slot="tip">{{tip_originFileName}}</div>
                                </el-upload>
                              </el-form-item>
                            </div>
                            <div class="bandTableItem_tips">
                              Tips：Sel_wave内波长以逗号隔开，Model上传文件以xml为后缀
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Water_Para Range</div>
                        <div class="bandTableItem_con">
                          <el-form-item label="" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">L:</div>
                              <el-input
                                v-model="item.paramRange.lower"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">U:</div>
                              <el-input
                                v-model="item.paramRange.upper"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                        </div>
                      </div>
                      <!-- 模型修正 -->
                      <div
                        class="bandTableItem"
                        v-if="modelData.id && modelData.id !== '' ? true : false"
                      >
                        <div class="bandTableItem_conLabel">Result Modify</div>
                        <div class="bandTableItem_con">
                          <el-form-item class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Coef:</div>
                              <el-input
                                v-model="item.resultCorrect.coef"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Inter:</div>
                              <el-input
                                v-model="item.resultCorrect.inter"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                        </div>
                      </div>
                    </div>

                    <!-- SVM参数详情 -->
                    <div v-if="item.SVRFlag">
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Pre-process</div>
                        <div class="bandTableItem_con">
                          <el-form-item label="Band_del" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Head:</div>
                              <el-input
                                v-model="item.bandDelete.startIndex"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Tail:</div>
                              <el-input
                                v-model="item.bandDelete.endIndex"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                          <el-form-item label="SG filtering" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">W:</div>
                              <el-input
                                v-model="item.deNoise.w"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">K:</div>
                              <el-input
                                v-model="item.deNoise.k"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                          <el-form-item label="Ref-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.informEnhance"
                              v-for="(refItem, index) in ref_process_list"
                              :label="refItem.value"
                              @input="change($event)"
                              :key="index"
                              >{{ refItem.name }}</el-radio
                            >
                          </el-form-item>
                          <el-form-item label="T-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.tProcess"
                              label="No"
                              @change="chooseT"
                              @input="change($event)"
                              >No</el-radio
                            >
                            <el-radio
                              v-model="item.tProcess"
                              label="R"
                              @change="chooseT"
                              @input="change($event)"
                              >R</el-radio
                            ><el-radio
                              v-model="item.tProcess"
                              label="recip"
                              @change="chooseT"
                              @input="change($event)"
                              >RE</el-radio
                            ><el-radio
                              v-model="item.tProcess"
                              label="expx"
                              @change="chooseT"
                              @input="change($event)"
                              >EXP</el-radio
                            >
                            <el-input
                              v-model="item.tPreCoef"
                              v-if="isTPreCoef"
                              style="width: 150px; margin-right: 20px"
                            ></el-input
                            ><el-radio
                              v-model="item.tProcess"
                              label="ln"
                              @change="chooseT"
                              @input="change($event)"
                              >LN</el-radio
                            >
                          </el-form-item>
                          <el-form-item label="TDS-process" class="bandTableItem_input">
                            <el-radio
                              v-model="item.tdsProcess"
                              label="No"
                              @change="chooseT"
                              @input="change($event)"
                              >No</el-radio
                            >
                            <el-radio
                              v-model="item.tdsProcess"
                              label="R"
                              @change="chooseTds"
                              @input="change($event)"
                              >R</el-radio
                            ><el-radio
                              v-model="item.tdsProcess"
                              label="recip"
                              @change="chooseTds"
                              @input="change($event)"
                              >RE</el-radio
                            ><el-radio
                              v-model="item.tdsProcess"
                              label="expx"
                              @change="chooseTds"
                              @input="change($event)"
                              >EXP</el-radio
                            >
                            <el-input
                              v-model="item.tdsPreCoef"
                              v-if="isTdsPreCoef "
                              style="width: 150px; margin-right: 20px"
                            ></el-input
                            ><el-radio
                              v-model="item.tdsProcess"
                              label="ln"
                              @change="chooseTds"
                              @input="change($event)"
                              >LN</el-radio
                            >
                          </el-form-item>
                        </div>
                      </div>
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Model</div>
                        <div class="bandTableItem_conBand">
                          <div
                            class="bandTableItem_conBandItem"
                            style="display: flex; flex-direction: column"
                          >
                            <div
                              class="bandTableItem_conBandItem_rf"
                              style="width: 100%"
                            >
                              <el-form-item
                                label-width="150px"
                                label="Model:"
                              >
                               <el-upload
                                  class="upload-demo"
                                  :action="rfuploadUrl"
                                  :headers="{
                                    'x-auth-token': token,
                                  }"
                                  :disabled="modelData.id && modelData.id !== '' ? true : false"
                                  :before-upload="rfBeforeUpload"
                                  :on-success="rfHandleSuccess"
                                  :limit="1"
                                  :file-list="rfFileList"
                                >
                                  <el-button size="small" type="primary"
                                    >点击上传</el-button
                                  >
                                  <div slot="tip">{{tip_originFileName}}</div>
                                </el-upload>
                              </el-form-item>
                            </div>
                          </div>
                          <div class="bandTableItem_tips" style="color:#b2b2b2">
                              Tips：Model上传文件以xml为后缀
                            </div>
                        </div>
                      </div>
                      <div class="bandTableItem">
                        <div class="bandTableItem_conLabel">Water_Para Range</div>
                        <div class="bandTableItem_con">
                          <el-form-item label="" class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">L:</div>
                              <el-input
                                v-model="item.paramRange.lower"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">U:</div>
                              <el-input
                                v-model="item.paramRange.upper"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                        </div>
                      </div>
                      <!-- 模型修正 -->
                      <div
                        class="bandTableItem"
                        v-if="modelData.id && modelData.id !== '' ? true : false"
                      >
                        <div class="bandTableItem_conLabel">Result Modify</div>
                        <div class="bandTableItem_con">
                          <el-form-item class="bandTableItem_input">
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Coef:</div>
                              <el-input
                                v-model="item.resultCorrect.coef"
                                @input="change($event)"
                              ></el-input>
                            </div>
                            <div class="bandTableItem_inputItem">
                              <div style="width: 80px">Inter:</div>
                              <el-input
                                v-model="item.resultCorrect.inter"
                                @input="change($event)"
                              ></el-input>
                            </div>
                          </el-form-item>
                        </div>
                      </div>
                    </div>

                  </div>
                </el-tab-pane>
              </el-tabs>
            </div>
          </el-form-item>

          <el-form-item label="Remarks">
            <el-input
              v-model="modelData.remark"
              style="width: 80%"
              @input="change($event)"
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer">
        <el-button @click="cancelConfigure">取 消</el-button>
        <el-button type="primary" @click="configureSave('modelDataForm')"
          >确 定</el-button
        >
      </div>
    </el-dialog>

    <!-- 模型查看窗口 -->
    <el-dialog
      title="指标模型"
      :visible.sync="showFormFlag"
      v-if="showFormFlag"
      width="80%"
      center
      modal
    >
      <div>
        <MetaPageTable
          ref="indexModelTable"
          class="dataConfigure_table"
          table-title="指标模型列表 "
          :is-auto-req="true"
          :req-url="modelReqUrl"
          :req-data="indexModelSearch"
          req-method="post"
          :display-item="modelDisplayItem"
          :line-btn-group="modelLineBtnGroup"
          @lineBtnClick="modelInLineBtnClick"
        />
      </div>
    </el-dialog>

    <!-- 模型校准窗口 -->
    <el-dialog
      v-if="calibrationFlag"
      title="模型校准"
      :visible.sync="calibrationFlag"
      width="70%"
      center
      modal
      :before-close="calibrationFormClose"
    >
      <div class="testFormClass">
        <el-form
          ref="calibrationForm"
          :model="calibrationForm"
          label-width="80px"
          style="width: 100%"
          :rules="calibrationFormRules"
        >
          <el-form-item
            label="设备选择"
            style="width: 80%"
            prop="equipmentId"
            label-width="180px"
          >
            <el-select
              style="width: 100%"
              v-model="calibrationForm.equipmentId"
              placeholder="请选择设备"
              filterable
            >
              <el-option
                v-for="item in equipmentList"
                :key="item.id"
                :label="item.equipmentName"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="校准时间选择"
            style="width: 80%"
            prop="time"
            label-width="180px"
          >
            <el-date-picker
              style="width: 100%"
              v-model="calibrationForm.time"
              type="datetimerange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd HH:mm:ss"
              @change="selectCalibrationTime"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item
            label="校准参数"
            style="width: 80%"
            label-width="180px"
            prop="params"
          >
            <el-select
              style="width: 100%"
              v-model="calibrationForm.params"
              placeholder="请选择参数"
              multiple
              clearable
              @change="selectParam($event)"
            >
              <el-option
                v-for="item in cali_paramsList"
                :key="item.paramkey"
                :label="item.paramname"
                :value="item.paramkey"
              >
              </el-option>
            </el-select>
          </el-form-item>
          
          <el-form-item label="数据列表" label-width="180px">
            <div class="bandTitle">
              <el-tabs v-model="paramChooseItem" @tab-click="calibrationClick">
                <el-tab-pane
                  v-for="item in buildDetails"
                  :key="item.key"
                  :label="item.label"
                  :name="item.label"
                >
                  <div class="bandTable" style="max-height: 300px; overflow: auto">
                    <div class="bandTableTitle">
                      <div class="bandTableTitleItem">原始数据时间</div>
                      <div class="bandTableTitleItem">计算值</div>
                      <div class="bandTableTitleItem">输入值</div>
                    </div>
                    <div class="bandTableDataBg">
                      <div class="bandTableData">
                        <div
                          class="bandTableDataItem"
                          v-for="(item, index) in timeList"
                          :key="index"
                        >
                          {{ item }}
                        </div>
                      </div>

                      <div class="bandTableData">
                        <div
                          class="bandTableDataItem"
                          v-for="(item, index) in resultValueList"
                          :key="index"
                        >
                          {{ item }}
                        </div>
                      </div>
                      <div class="bandTableData">
                        <div
                          class="bandTableDataItem"
                          v-for="(item, index) in dataEntryList"
                          :key="index"
                        >
                          {{ item }}
                        </div>
                      </div>
                    </div>
                  </div>
                </el-tab-pane>
              </el-tabs>
            </div>
          </el-form-item>
          <el-form-item label="备注" label-width="180px" style="width: 80%">
            <el-input
              v-model="calibrationForm.remark"
              style="width: 100%"
              @input="change($event)"
            ></el-input>
          </el-form-item>
        </el-form>
      </div>

      <div slot="footer">
        <el-button @click="calibrationFormClose">取 消</el-button>
        <el-button type="primary" @click="calibrationFinish">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 测试窗口 -->
    <el-dialog
      v-if="testFormFlag"
      title="模型测试"
      :visible.sync="testFormFlag"
      width="70%"
      center
      modal
      :before-close="testFormClose"
    >
      <div class="testFormClass">
        <el-form
          ref="testForm"
          :model="testForm"
          label-width="80px"
          style="width: 100%"
          :rules="testFormRules"
        >
          <el-form-item
            label="设备选择"
            style="width: 80%"
            prop="equipmentId"
            label-width="180px"
          >
            <el-select v-model="testForm.equipmentId" placeholder="请选择设备" filterable>
              <el-option
                v-for="item in equipmentList"
                :key="item.id"
                :label="item.equipmentName"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="原始数据时间选择"
            style="width: 80%"
            prop="time"
            label-width="180px"
          >
            <el-date-picker
              v-model="testForm.time"
              type="datetimerange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd HH:mm:ss"
              @change="selectTime"
            >
            </el-date-picker>
          </el-form-item>
        </el-form>
        <el-button
          type="primary"
          @click="saveTestForm('testForm')"
          style="float: right; margin-top: -60px"
          >开始测试</el-button
        >
      </div>
      <div>
        <div style="text-align: center; font-size: 16px; margin-bottom: 20px">
          模型测试结果
        </div>
        <MetaPageTable
          ref="modelTestTable"
          class="modelOptimization_table"
          :tableTitle="testTitle"
          :is-auto-req="false"
          req-method="post"
          :btn-group="testbtnGroup"
          :table-data="testTableData"
          :display-item="testDisplayItem"
          @btnClick="testtableBtnClick"
        />
      </div>
      <!-- <div slot="footer">
        <el-button @click="testFormClose">取 消</el-button>
        <el-button type="primary" @click="testFormClose">确 定</el-button>
      </div> -->
    </el-dialog>

    <!-- 重命名窗口 -->
    <el-dialog
      title="指标模型重命名"
      :visible.sync="renameFormFlag"
      v-if="renameFormFlag"
      width="60%"
      :before-close="renameCancel"
      center
      modal
    >
      <div>
        <el-form
          :model="renameForm"
          label-width="150px"
          :rules="renameFormRules"
          ref="renameForm"
        >
          <el-form-item label=" 模型名称" style="width: 80%">
            <div>{{ renameForm.modelName }}</div>
          </el-form-item>
          <el-form-item label=" 模型重命名" style="width: 80%" prop="rename">
            <el-input v-model="renameForm.rename"></el-input>
          </el-form-item>
        </el-form>
      </div>

      <div slot="footer">
        <el-button @click="renameCancel">取 消</el-button>
        <el-button type="primary" @click="renameFinish">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 模型导出窗口 -->
    <el-dialog
      title="模型导出"
      :visible.sync="exportDialogFlag"
      v-if="exportDialogFlag"
      width="60%"
      center
      modal
    >
      <div class="exportForm">
        <el-form :model="exportForm" label-width="150px">
          <el-form-item label="设备" class="dataConfigure_searchFormItem">
            <el-select
              v-model="exportForm.equipmentId"
              placeholder="请选择设备"
              filterable
              clearable
            >
              <el-option
                v-for="item in equipmentList"
                :key="item.id"
                :label="item.equipmentName"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="模型构建时间" class="dataConfigure_searchFormItem">
            <el-date-picker
              v-model="exportFormTime"
              type="datetimerange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd HH:mm:ss"
              @change="chooseTime"
            >
            </el-date-picker>
          </el-form-item>
        </el-form>
      </div>

      <div slot="footer">
        <el-button @click="exportCancel">取 消</el-button>
        <el-button type="primary" @click="exportFinish">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 模型导入窗口 -->
    <el-dialog
      title="模型导入"
      :visible.sync="importDialogFlag"
      v-if="importDialogFlag"
      width="60%"
      :before-close="importCancel"
      center
      modal
    >
      <div class="exportForm">
        <el-form :model="importForm" label-width="150px">
          <el-form-item label="设备">
            <el-select
              v-model="importForm.equipmentId"
              placeholder="请选择设备"
              filterable
              clearable
            >
              <el-option
                v-for="item in equipmentList"
                :key="item.id"
                :label="item.equipmentName"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="文件上传" prop="upload">
            <el-upload
              class="upload-demo"
              :action="uploadUrl"
              :headers="{
                'x-auth-token': token,
              }"
              :data="importForm"
              :limit="1"
              :file-list="fileList"
              :on-success="uploadSuccess"
              :before-upload="beforeUpload"
            >
              <el-button size="small" type="primary">上传文件并保存</el-button>
              <div slot="tip" class="el-upload__tip">只能上传xlsx或xls格式文件</div>
            </el-upload>
          </el-form-item>
        </el-form>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import MetaPageTable from "../components/MetaPageTable";
import MetaSearchForm from "../components/MetaSearchForm";
import deepClone from "../utils/deepClone";
import utils from "../utils/utils";
import { validateLetterNumberWord } from "../utils/validate";

export default {
  name: "dataComfigure",
  components: {
    MetaPageTable,
    MetaSearchForm,
  },
  data() {
    let checkName = (rule, value, callback) => {
      if (!value) {
        callback(new Error("必填项不可为空"));
      } else {
        if (value.length > 50) {
          callback(new Error("内容录入过长"));
        } else if (!validateLetterNumberWord(value)) {
          callback(new Error("请准确输入名称"));
        } else {
          return callback();
        }
      }
    };

    return {
      token: localStorage.getItem("token"),
      newModelDialog: false,
      RandomFlag: false,
      BandFlag: false,
      PolynomialFlag: false,
      TdsFlag: false,
      exportDialogFlag: false,
      importDialogFlag: false,
      isSel_wave: false,
      isTPreCoef: false,
      isTdsPreCoef: false,
      rfuploadUrl: process.env.PROGOO_GATE_WATER + "rTrees/upload",
      uploadUrl: process.env.PROGOO_GATE_WATER + "admin/model/import",
      modelReqUrl: process.env.PROGOO_GATE_WATER + "model/getList",
      username: "",
      lastModelId: "", //模型迭代时上次的模型Id
      lastModelwaterParameters: [], //模型迭代时上次的水质参数  模型迭代时设备和参数不可修改 暂存
      paramActive: "",
      randomList: [],
      modelTypeList: [
        { value: "随机组合", id: "Random" },
        { value: "波段组合", id: "Band" },
        { value: "多项式组合", id: "Polynomial" },
        { value: "T&TDS", id: "TAndTds" },
        { value: "Poly_F", id: "PolyF" },
        { value: "随机森林", id: "RTrees" },
        { value: "SVR", id: "Svr" },
      ],
      modelSearch: {
        equipmentId: "",
        modelType: "",
        modelTempId: "",
        equipmentId: "",
        dateBetween: "",
        type: "manual",
        username: localStorage.getItem("username"),
      },
      indexModelSearch: {
        modelTempId: "",
        username: localStorage.getItem("username"),
      },
      modelData: {
        id: "",
        equipmentId: "",
        equipmentName: "",
        waterParameters: "",
        methodType: "",
        remark: "",
      },
      buildDetails: [],
      methodType_list: [
        { name: "Random", value: "Random" },
        { name: "Band", value: "Band" },
        { name: "Polynomial", value: "Polynomial" },
        { name: "T&TDS", value: "TAndTds" },
        { name: "Poly_F", value: "PolyF" },
        { name: "RF", value: "RTrees" },
        { name: "SVR", value: "Svr" },
      ],
      ref_process_list: [
        { name: "R", value: "R" },
        { name: "D1", value: "derivatives1" },
        { name: "D2", value: "derivatives2" },
        { name: "EXP", value: "exp" },
        { name: "LN", value: "ln" },
        { name: "ED1", value: "expDerivativesFirst" },
        { name: "LD1", value: "lnDerivativesFirst" },
      ],
     
      modelDataRules: {
        equipmentId: [{ required: true, message: "请选择设备", trigger: "blur" }],
        waterParameters: [{ required: true, message: "请选择参数", trigger: "blur" }],
        methodType: [{ required: true, message: "请选择方法", trigger: "change" }],
        remark: [{ required: true, message: "请输入备注", trigger: "blur" }],
      },
      renameFormRules: {
        rename: [
          {
            required: true,
            validator: checkName,
            trigger: "blur",
          },
        ],
      },
      paramChooseItem: 0,
      randomNum: {
        value: [],
        band_content: [],
        poly_content: [],
        tds_content: [],
      },
      resultCorrect: {
        inter: "",
        coef: "",
      },
      reqUrl: process.env.PROGOO_GATE_WATER + "model/getModelResult",
      dataReqUrl: process.env.PROGOO_GATE_WATER + "admin/dataList",
      displayItem: [
        {
          label: "设备",
          prop: "equipmentName",
        },
        {
          label: "模型构建时间",
          prop: "createDate",
        },

        {
          label: "构建状态",
          prop: "modelStatus",
          type: "if",
          format: {
            "00": "构建中",
            "01": "完成",
            "02": "构建失败",
          },
          color: {
            "00": "orange",
            "01": "LimeGreen",
            "02": "red",
          },
          width: "100",
        },
        {
          label: "构建完成时间",
          prop: "completeDate",
        },
        {
          label: "备注",
          prop: "remark",
        },
      ],
      testTableData: {},
      linkedId: "",
      testDisplayItem: [{ label: "原始数据时间", prop: "pickTime" }],
      modelDisplayItem: [
        {
          label: "设备",
          prop: "equipmentName",
          width: "130",
        },
        {
          label: "参数",
          prop: "paramKey",
          type: "enum",
          enums: [],
          width: "130",
        },
        {
          label: "模型名称",
          prop: "modelName",
        },
        {
          label: "别名",
          prop: "modelNickname",
          width: "200",
        },
        {
          label: "构建方法",
          prop: "modelType",
          type: "if",
          format: {
            Random: "随机组合",
            Band: "波段组合",
            Polynomial: " 多项式组合",
            TAndTds: "T&TDS",
          },
          width: "100",
        },

        {
          label: "优化完成时间",
          prop: "completeDate",
          width: "200",
        },
        {
          label: "备注",
          prop: "remark",
          width: "200",
        },
      ],
      dataDisplayItem: [],
      btnGroup: [
        {
          id: "model_import",
          title: "模型导入",
        },
        {
          id: "model_export",
          title: "模型导出",
        },
        {
          id: "newModel",
          title: "手动构建",
        },
      ],
      testEq: "",
      testTime: "",
      testTitle: "",
      testbtnGroup: [
        {
          id: "test_export",
          title: "导出",
        },
      ],
      lineBtnGroup: [
        {
          id: "show",
          title: "指标模型",
        },
        {
          id: "edit",
          title: "模型迭代",
        },
        {
          id: "test",
          title: "测试",
        },
        {
          id: "calibration",
          title: "校准",
        },
        {
          id: "delete",
          title: "删除",
        },
      ],
      modelLineBtnGroup: [
        {
          id: "rename",
          title: "重命名",
        },

        {
          id: "modelDelete",
          title: "删除",
        },
      ],
      itemExportData: {
        dateBetween: [],
      },
      rolesList: [],
      companyList: [],
      equipmentList: [],
      splitDisplayItem: {
        sign: ",",
        label: "modelName",
        prop: "modelKey",
        value: "modelValue",
      },
      optimizeForm: {
        equipment: "",
        dateBetween: "",
        selectId: [],
        type: "",
      },
      tabIndex: 0,
      testForm: {
        equipmentId: "",
        time: [],
        dateStart: "",
        dateEnd: "",
      },
      calibrationForm: {
        equipmentId: "",
        params: [],
        time: "",
        modelTempId:"",
        dateStart: "",
        dateEnd: "",
        remark: "",
      },
      testParamOption: "",
      testFormRules: {
        equipmentId: [{ required: true, message: "请选择设备", trigger: "blur" }],
        time: [{ required: true, message: "请选择时间", trigger: "blur" }],
      },
      calibrationFormRules: {
        equipmentId: [{ required: true, message: "请选择设备", trigger: "blur" }],
        params: [{ required: true, message: "请选择参数", trigger: "blur" }],
        time: [{ required: true, message: "请选择时间", trigger: "blur" }],
      },
      exportForm: {
        equipmentId: "",
      },
      importForm: {
        username: localStorage.getItem("username"),
        equipmentId: "",
      },
      exportFormTime: "",
      paramsList: [],
      cali_paramsList:[],   //模型校准时参数选择列表
      modelIteration: "",
      evaluate: "",
      modelName: "",
      testFormFlag: false,
      showFormFlag: false,
      calibrationFlag: false,
      testResultFormFlag: false,
      renameFormFlag: false,
      renameId: "",
      rename: "",
      testResult: [],
      renameForm: { modelName: "", rename: "" },
      dataEntryTableData: {},
      itemId: "",
      timeList: [],
      dataEntryList: [],          //校准输入值
      resultValueList: [],        //校准计算值
      fileList: [],
      rfFileList: [],
      tip_originFileName: "",
      originFileName: ""
    };
  },
  mounted() {
    this.searchModelFromAlgo();
    this.username = localStorage.getItem("username");
    this.getEquipment();
    this.getParams();
  },
  methods: {
    searchModelFromAlgo() {
      if (this.$route.params.modelTempId) {
        this.modelSearch.modelTempId = this.$route.params.modelTempId;
        this.modelSearch.equipmentId = this.$route.params.equipmentId;
        this.$nextTick(() => {
          this.$refs.dataConfigureTable.formDataInit(true);
        });
      }
    },
    tableBtnClick(item) {
      if (item.button === "newModel") {
        //新建模型
        this.lastModelId = "";
        this.newModelDialog = true;
      } else if (item.button === "model_export") {
        this.exportDialogFlag = true;
      } else if (item.button === "model_import") {
        this.importDialogFlag = true;
      }
    },
    tableInlineBtnClick(item) {
      if (item.button === "show") {
        this.showFormFlag = true;
        this.indexModelSearch.modelTempId = item.rows.id;
        this.$nextTick(() => {
          this.$refs.indexModelTable.formDataInit(true);
        });
      } else if (item.button === "test") {
        //模型测试

        this.linkedId = item.rows.linkedId;
        this.testTableData = {};
        this.itemId = item.rows.id;
        this.testForm.equipmentId = item.rows.equipmentId;
        this.$fetch({
          url: process.env.PROGOO_GATE_WATER + "model/iteration",
          method: "post",
          data: {
            id: item.rows.id,
          },
        }).then((res) => {
          if (res.data.code === 200) {
            this.testParamOption = res.data.result.waterParameters;

            this.getTestResult(1, () => {
              this.testFormFlag = true;
            });
          }
        });
      } else if (item.button === "calibration") {
        this.calibrationForm.modelTempId = item.rows.id
        this.calibrationFlag = true;
        this.cali_paramsList = []
        this.$fetch({
          url: process.env.PROGOO_GATE_WATER + "model/calibrationKeys",
          method: "post",
          data: {
            modelTempId: this.calibrationForm.modelTempId,
          },
        }).then((res) => {
          if(res.data.code == 200){
            if(res.data.result.length !== 0){
                let tempList = res.data.result
                for(let i in tempList){
                  let item = {}
                  item.paramkey = tempList[i].paramKey
                  item.paramname = tempList[i].paramName
                  this.cali_paramsList.push(item)
                }
            }
          }
        })
      } else if (item.button === "fix") {
        //模型修正 待定
      } else if (item.button === "edit") {
        //模型修正 待定
        console.log(this.tabIndex)
        this.modelData.equipmentId = "";
        this.$fetch({
          url: process.env.PROGOO_GATE_WATER + "model/iteration",
          method: "post",
          data: {
            id: item.rows.id,
          },
        }).then((res) => {
          if (res.data.code === 200) {
            //分为新版本和老版本
            this.newModelDialog = true;
            this.modelData.id = item.rows.id;
            this.paramTabList = res.data.result.waterParameters;
            this.lastModelId = item.rows.id;
            this.buildDetails = [];
            this.modelData.equipmentId = item.rows.equipmentId;
            this.lastModelwaterParameters = res.data.result.waterParameters;
            this.modelIteration = "";
            this.modelData.equipmentName = res.data.result.equipmentName;
            this.modelData.remark = item.rows.remark;
            for (let i in res.data.result.model) {
              this.buildDetails.push(res.data.result.model[i]);
              for (let j in this.buildDetails) {
                if (this.buildDetails[j].methodType === "Random") {
                  //  delete this.buildDetails[j].resultCorrect;
                  this.buildDetails[j].RandomFlag = true;
                } else if (this.buildDetails[j].methodType === "Band") {
                  this.buildDetails[j].BandFlag = true;
                } else if (this.buildDetails[j].methodType === "Polynomial") {
                  this.buildDetails[j].PolyFlag = true;
                } else if (this.buildDetails[j].methodType === "TAndTds") {
                  this.buildDetails[j].TdsFlag = true;
                } else if (this.buildDetails[j].methodType === "PolyF") {
                  this.buildDetails[j].Poly_FFlag = true;
                } else if (this.buildDetails[j].methodType === "RTrees") {
                  this.buildDetails[j].RFFlag = true;
                  if(this.buildDetails[j].rfBandMath.waveType === "Sel_wave"){
                    this.isSel_wave = true
                  }else {
                    this.isSel_wave = false
                  }
                } else if (this.buildDetails[j].methodType === "Svr") {
                  this.buildDetails[j].SVRFlag = true;
                }
              }
              let tempParameters = [];
              for (let i in res.data.result.model) {
                tempParameters.push(res.data.result.model[i].label);
              }
              this.modelIteration = tempParameters.toString();
            }
          }
        });
      } else if (item.button === "delete") {
        this.$confirm("确认删除当前模型？", "确认删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.$fetch({
              url: process.env.PROGOO_GATE_WATER + "model/remove",
              method: "delete",
              data: {
                id: item.rows.id,
                username: this.username,
              },
            }).then((res) => {
              if (res.data.code === 200) {
                if (res.data.message == "成功") {
                  this.$message({
                    type: "success",
                    message: "操作成功!",
                  });
                  this.$nextTick(() => {
                    this.$refs.dataConfigureTable.formDataInit(true);
                  });
                } else if (res.data.message == "模型占用") {
                  this.$confirm(
                    "“" +
                      res.data.result[0] +
                      "”" +
                      "模型被" +
                      "“" +
                      res.data.result[1] +
                      "”" +
                      "算法占用，请解除后删除!",
                    "模型被占用",
                    {
                      confirmButtonText: "跳转至算法管理",
                      cancelButtonText: "取消",
                      type: "warning",
                    }
                  )
                    .then(() => {
                      this.$router.push({
                        path: "/algorithmManagement",
                        query: {
                          searchAlgo: res.data.result[1],
                        },
                      });
                    })
                    .catch(() => {});
                }
              } else {
                this.$notify.error({
                  title: "错误",
                  message: res.data.message,
                });
              }
            });
          })
          .catch(() => {});
      }
    },
    modelInLineBtnClick(item) {
      if (item.button === "rename") {
        //重命名
        this.renameFormFlag = true;
        this.renameId = item.rows.id;
        this.renameForm.modelName = item.rows.modelName;
      } else if (item.button === "modelDelete") {
        this.$confirm("确认删除当前模型？", "确认删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.$fetch({
              url: process.env.PROGOO_GATE_WATER + "evaluation/remove",
              method: "delete",
              data: {
                id: item.rows.id,
              },
            }).then((res) => {
              if (res.data.code === 200) {
                if (res.data.message == "成功") {
                  this.$notify.success({
                    title: "成功",
                    message: "模型删除成功",
                  });
                  this.$nextTick(() => {
                    this.$refs.indexModelTable.formDataInit(true);
                  });
                } else if (res.data.message == "模型占用") {
                  this.$confirm(
                    "当前模型被“" + res.data.result + "”算法占用",
                    "模型被占用",
                    {
                      confirmButtonText: "跳转至算法管理",
                      cancelButtonText: "取消",
                      type: "warning",
                    }
                  )
                    .then(() => {
                      this.$router.push({
                        path: "/algorithmManagement",
                        query: {
                          searchAlgo: res.data.result,
                        },
                      });
                    })
                    .catch(() => {});
                }
              } else {
                this.$notify.error({
                  title: "删除失败",
                  message: res.data.result,
                });
              }
            });
          })
          .catch(() => {});
      }
    },
    testtableBtnClick(item) {
      if (item.button === "test_export") {
        //重命名
        this.exportResult(this.linkedId);
      }
    },
    showMethods(value) {
      this.buildDetails[this.tabIndex].RandomFlag = false;
      this.buildDetails[this.tabIndex].BandFlag = false;
      this.buildDetails[this.tabIndex].PolyFlag = false;
      this.buildDetails[this.tabIndex].TdsFlag = false;
      this.buildDetails[this.tabIndex].Poly_FFlag = false;
      this.buildDetails[this.tabIndex].RFFlag = false;
      this.buildDetails[this.tabIndex].SVRFlag = false;
      if (value == "Random") {
        this.buildDetails[this.tabIndex].RandomFlag = true;
      } else if (value == "Band") {
        this.buildDetails[this.tabIndex].BandFlag = true;
      } else if (value == "Polynomial") {
        this.buildDetails[this.tabIndex].PolyFlag = true;
      } else if (value == "TAndTds") {
        this.buildDetails[this.tabIndex].TdsFlag = true;
      } else if (value == "PolyF") {
        this.buildDetails[this.tabIndex].Poly_FFlag = true;
      } else if (value == "RTrees") {
        this.buildDetails[this.tabIndex].RFFlag = true;
      } else if (value == "Svr") {
        this.buildDetails[this.tabIndex].SVRFlag = true;
      }
    },
    getTestResult(page, callback) {
      this.$fetch({
        url: process.env.PROGOO_GATE_WATER + "model/result",
        method: "post",
        data: {
          id: this.itemId,
          username: this.username,
        },
      }).then((res) => {
        if (res.data.code === 200) {
          this.testResult = res.data.result;
          this.testTableData = {};
          this.testTableData.page = page;
          this.testTableData.totalElements = this.testResult.value.length;
          this.testTableData.content = this.testResult.value;
          this.testDisplayItem = [{ label: "原始数据时间", prop: "pickTime" }];
          if (this.testResult.param.length > 0) {
            for (let i = 0; i < this.testResult.param.length; i++) {
              if (this.testResult.param[i].unit) {
                this.testResult.param[i].label =
                  this.testResult.param[i].name +
                  "(" +
                  this.testResult.param[i].unit +
                  ")";
              } else {
                this.testResult.param[i].label = this.testResult.param[i].name;
              }
              this.testResult.param[i].prop = this.testResult.param[i].key;
              this.testDisplayItem.push(this.testResult.param[i]);
            }
            for (let i in this.equipmentList) {
              if (this.equipmentList[i].id === this.testResult.equipmentId) {
                this.testEq = this.equipmentList[i].equipmentName;
              }
            }
            this.testTime =
              this.testResult.value[this.testResult.value.length - 1].pickTime +
              "-" +
              this.testResult.value[0].pickTime;
            this.testTitle = this.testEq + "_" + this.testTime;
          } else {
            this.testDisplayItem = [{ label: "原始数据时间", prop: "pickTime" }];
          }
          if (callback && typeof callback === "function") {
            callback();
          }
          this.$nextTick(() => {
            this.$refs.modelTestTable.formDataInit("all");
          });
        }
      });
    },
    getEquipment() {
      this.$fetch({
        url: process.env.PROGOO_GATE_WATER + "admin/algorithm/equipmentList",
        method: "get",
        data: {},
      }).then((res) => {
        if (res.data.code === 200) {
          this.equipmentList = res.data.result;
          this.optimizeForm.equipment = this.equipmentList[0].equipmentName;
          this.optimizeForm.equipmentId = this.equipmentList[0].id;
        } else {
          this.$notify.error({
            title: "错误",
            message: res.data.message,
          });
        }
      });
    },
    // 获取参数
    getParams() {
      this.$fetch({
        url: process.env.PROGOO_GATE_WATER + "admin/paramThreshold",
        method: "post",
        data: {
          page: 1,
          limit: 999,
        },
      }).then((res) => {
        if (res.data.code === 200) {
          this.paramsList = res.data.result.content;
          this.paramsList.reverse();
          for (let i in this.displayItem) {
            if (this.displayItem[i].prop === "paramKey") {
              this.displayItem[i].enums = [];
              for (let l in this.paramsList) {
                let item = this.paramsList[l];
                item.value = this.paramsList[l].paramkey;
                item.text = this.paramsList[l].paramname;
                this.displayItem[i].enums.push(item);
              }
            }
          }
          for (let i in this.modelDisplayItem) {
            if (this.modelDisplayItem[i].prop === "paramKey") {
              this.modelDisplayItem[i].enums = [];
              for (let l in this.paramsList) {
                let item = this.paramsList[l];
                item.value = this.paramsList[l].paramkey;
                item.text = this.paramsList[l].paramname;
                this.modelDisplayItem[i].enums.push(item);
              }
            }
          }
        } else {
          this.$notify.error({
            title: "错误",
            message: res.data.message,
          });
        }
      });
    },

    tableSearch() {
      let param = {};
      for (let key in this.modelSearch) {
        if (key === "dateBetween") {
          param.dateStart =
            this.modelSearch[key] && this.modelSearch[key].length > 0
              ? this.modelSearch[key][0] + " 00:00:00"
              : "";
          param.dateEnd =
            this.modelSearch[key] && this.modelSearch[key].length > 0
              ? this.modelSearch[key][1] + " 23:59:59"
              : "";
        } else {
          param[key] = this.modelSearch[key];
        }
      }
      this.modelSearch = param;
      this.$nextTick(() => {
        this.$refs.dataConfigureTable.formDataInit(true);
      });
    },
    beforeUpload(file) {
      let excelfileExtend = ".xlsx.xls"; //设置文件格式
      let fileExtend = file.name.substring(file.name.lastIndexOf(".")).toLowerCase();
      if (excelfileExtend.indexOf(fileExtend) <= -1) {
        this.$message.error("文件格式错误");
        return;
      }
    },
    uploadSuccess(response, file, fileList) {
      this.fileList = [];

      if (this.importForm.equipmentId === "") {
        this.$notify.warning({
          title: "警告",
          message: "请选择设备进行导入!",
        });
      }
      if (response.code == 200) {
        if (response.message == "成功") {
          this.$notify.success({
            title: "成功",
            message: "数据导入成功!",
          });
          this.importDialogFlag = false;
          this.importForm.equipmentId = "";
          this.$nextTick(() => {
            this.$refs.dataConfigureTable.formDataInit(true);
          });
        } else if (response.message == "重复") {
          this.$notify.warning({
            title: "警告",
            message: "该模型已经导入!",
          });
        }
      } else if (response.code == 400) {
        this.$notify.error({
          title: "失败",
          message: "数据导入失败!",
        });
      }
    },
    showEquipmentName(e) {
      for (let i in this.equipmentList) {
        if (e == this.equipmentList[i].id) {
          this.modelData.equipmentName = this.equipmentList[i].equipmentName;
        }
      }
    },
    testFormClose() {
      this.testDisplayItem = [{ label: "原始数据时间", prop: "pickTime" }];
      this.testFormFlag = false;
      this.testTitle = "";
    },
    change(e) {
      //强制刷新组件
      this.$forceUpdate();
    },
    rfBeforeUpload(file) {
      this.originFileName = file.name
      let excelfileExtend = ".xml"; //设置文件格式
      let fileExtend = file.name.substring(file.name.lastIndexOf(".")).toLowerCase();
      if (excelfileExtend.indexOf(fileExtend) <= -1) {
        this.$notify.error({
          title: "上传失败",
          message: "文件格式错误!",
        });
        return;
      }
    },
    rfHandleSuccess(file) {
      this.buildDetails[this.tabIndex].fileName = file;
      this.buildDetails[this.tabIndex].originFileName = this.originFileName
    },
    selectTime(e) {
      this.testForm.dateStart = e[0];
      this.testForm.dateEnd = e[1];
    },
    selectCalibrationTime(e) {
      this.calibrationForm.dateStart = e[0];
      this.calibrationForm.dateEnd = e[1];
    },
    chooseTime(e) {
      this.exportForm.dateStart = e[0];
      this.exportForm.dateEnd = e[1];
    },
    chooseT(e) {
      console.log(e)
      this.isTPreCoef = false;
      if (e == "expx") {
        this.isTPreCoef = true;
      }else{
        this.isTPreCoef = false;
      }
    },
    chooseTds(e) {
      console.log(e)
      this.isTdsPreCoef = false;
      if (e == "expx") {
        this.isTdsPreCoef = true;
      }else{
        this.isTdsPreCoef = false;
      }
    },
    chooseWave(e){
      console.log(e)
      if (e == "Sel_wave") {
        this.isSel_wave = true;
      }else{
        this.isSel_wave = false;
      }
    },
    saveTestForm(formName) {
      //保存测试表单
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let param = {};
          param.id = this.itemId;
          param.username = this.username;
          param.equipmentId = this.testForm.equipmentId;
          param.dateStart = this.testForm.dateStart;
          param.dateEnd = this.testForm.dateEnd;
          this.$fetch({
            url: process.env.PROGOO_GATE_WATER + "model/verification",
            method: "post",
            data: param,
          }).then((res) => {
            if (res.data.code === 200) {
              this.$notify.success({
                title: "成功",
                message: "请稍后查看结果数据",
              });
              this.testFormFlag = false;
              this.testForm.time = "";
            }
          });
        } else {
          this.$notify.error({
            title: "失败",
            message: "请输入完整内容",
          });
        }
      });
    },
    exportResult(id) {
      //导出测试结果方法
      let token = localStorage.getItem("token");
      this.axios({
        method: "post",
        url: process.env.PROGOO_GATE_WATER + "admin/model/constructExport",
        data: {
          linkedId: id,
          username: this.username,
        },
        // token
        headers: {
          "x-auth-token": token,
        },
        responseType: "blob",
      }).then((res) => {
        if (res.data.code && res.data.code == 400) {
          this.$notify.error({
            title: "错误",
            message: res.data.message,
          });
          return;
        }
        const url = window.URL.createObjectURL(new Blob([res.data]));
        const link = document.createElement("a");
        link.style.display = "none";
        link.href = url;
        link.setAttribute("download", "模型测试结果.xlsx");
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
      });
    },
    exportFinish() {
      let token = localStorage.getItem("token");
      this.axios({
        method: "post",
        url: process.env.PROGOO_GATE_WATER + "admin/model/export",
        data: this.exportForm,
        // token
        headers: {
          "x-auth-token": token,
        },
        responseType: "blob",
      }).then((res) => {
        if (res.data.code && res.data.code == 400) {
          this.$notify.error({
            title: "错误",
            message: res.data.message,
          });
          return;
        }
        const url = window.URL.createObjectURL(new Blob([res.data]));
        const link = document.createElement("a");
        link.style.display = "none";
        link.href = url;
        link.setAttribute("download", "模型数据.xlsx");
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
        this.exportDialogFlag = false;
      });
    },
    exportCancel() {
      this.exportForm = {};
      this.exportDialogFlag = false;
    },
    handleClick(tab) {
      this.tabIndex = tab.index;
      this.tip_originFileName = this.buildDetails[this.tabIndex].originFileName
      console.log(this.tip_originFileName)
      if(this.buildDetails[this.tabIndex].rfBandMath.waveType == 'Sel_wave'){
        this.isSel_wave = true
      }else{
        this.isSel_wave = false
      }if(this.buildDetails[this.tabIndex].tProcess == 'expx'){
        this.isTPreCoef = true
      }else{
        this.isTPreCoef = false
      }if(this.buildDetails[this.tabIndex].tdsProcess == 'expx'){
        this.isTdsPreCoef = true
      }else{
        this.isTdsPreCoef = false
      }
     
    },
    selectParam(event) {
      this.paramActive = event; //获取option对应的value值
      this.paramTabList = [];
      for (let i in this.paramsList) {
        this.buildDetails = [];
        for (let j in this.paramActive) {
          if (this.paramsList[i].paramkey === this.paramActive[j]) {
            this.paramTabList.push(this.paramsList[i]);
            break;
          }
        }
      }
      for (let k in this.paramTabList) {
        this.buildDetails.push({
          methodType: "Band",
          fileName: "",
          originFileName: "",
          RandomFlag: false,
          BandFlag: true,
          PolyFlag: false,
          TdsFlag: false,
          Poly_FFlag: false,
          RFFlag: false,
          SVRFlag: false,
          key: this.paramTabList[k].paramkey,
          label: this.paramTabList[k].paramname,
          upper: "",
          lower: "",
          bandDelete: {
            // 波段剔除
            startIndex: "50",
            endIndex: "252",
          },
          deNoise: {
            //光谱去噪
            w: "5",
            k: "3",
          },
          paramRange: {
            upper: "",
            lower: "",
          },
          resultCorrect: {
            inter: "",
            coef: "",
          },
          informEnhance: "R", //信息增强
          tProcess: "R",
          tdsPreCoef: "",
          tPreCoef: "",
          tdsProcess: "R",
          polynomialBandMath: {
            // Polynomial
            featureBand: "",
            modelPara: "",
            method: "polynome",
          },
          bandCombineMath: {
            //波段组合
            method: "DValue",
            featureBand: "",
            modelPara: "",
          },
          tdsBandMath: {
            // tds
            // wave: "",
            central_wavelength: "",
            wave_modelPara: "",
            //T: "",
            T_modelPara: "0,0",
            //TDS: "",
            TDS_modelPara: "0,0",
          },
          rfBandMath: {
            // rf
            // wave: "",
            central_wavelength: "",
            waveType: "All_wave",
          },
          bandDelete: {
            // 波段剔除
            startIndex: "50",
            endIndex: "252",
          },
        });
      }
    },
    renameFinish() {
      //模型重命名方法
      this.$refs["renameForm"].validate((valid) => {
        if (valid) {
          this.$fetch({
            url: process.env.PROGOO_GATE_WATER + "admin/model/edit",
            method: "post",
            data: {
              modelNickname: this.renameForm.rename,
              id: this.renameId,
            },
          }).then((res) => {
            if (res.data.code === 200) {
              this.renameFormFlag = false;
              this.$notify.success({
                title: "成功",
                message: "指标模型重命名成功",
              });
              this.renameForm.rename = "";
              this.$nextTick(() => {
                this.$refs.indexModelTable.formDataInit(true);
              });
            }
          });
        }
      });
    },
    renameCancel() {
      this.renameFormFlag = false;
      this.renameForm.rename = "";
    },
    configureSave(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let manualParam = {};
          manualParam.equipmentName = this.modelData.equipmentName;
          manualParam.equipmentId = this.modelData.equipmentId;
          for (let i in this.buildDetails) {
            
            if(this.buildDetails[i].methodType === "Random"){
              delete this.buildDetails[i].BandFlag;
              delete this.buildDetails[i].Poly_FFlag;
              delete this.buildDetails[i].PolyFlag;
              delete this.buildDetails[i].TdsFlag;
              delete this.buildDetails[i].RFFlag;
              delete this.buildDetails[i].SVRFlag;
              //band 参数
              delete this.buildDetails[i].bandCombineMath;
              delete this.buildDetails[i].bandDelete;
              delete this.buildDetails[i].deNoise;
              delete this.buildDetails[i].informEnhance;
              delete this.buildDetails[i].paramRange;
              //polynomial参数
              delete this.buildDetails[i].polynomialBandMath;
              //TDS参数
              delete this.buildDetails[i].tProcess;
              delete this.buildDetails[i].tdsProcess;
              delete this.buildDetails[i].tPreCoef;
              delete this.buildDetails[i].tdsPreCoef;
              //rf参数
              delete this.buildDetails[i].rfBandMath;
              delete this.buildDetails[i].tdsBandMath;
              delete this.buildDetails[i].originFileName;
              delete this.buildDetails[i].fileName;
            }else{
               //random参数
              if(this.buildDetails[i].bandDelete.startIndex < 0){
                this.buildDetails[i].bandDelete.startIndex = "0"
              }else if(this.buildDetails[i].bandDelete.endIndex >= 302){
                this.buildDetails[i].bandDelete.endIndex = "302"
              }
              delete this.buildDetails[i].upper;
              delete this.buildDetails[i].lower;
              delete this.buildDetails[i].RandomFlag;
               if (this.buildDetails[i].methodType === "Band") {
                  delete this.buildDetails[i].PolyFlag;
                  delete this.buildDetails[i].TdsFlag;
                  delete this.buildDetails[i].Poly_FFlag;
                  delete this.buildDetails[i].RFFlag;
                  delete this.buildDetails[i].SVRFlag;
                  //polynomial参数
                  delete this.buildDetails[i].polynomialBandMath;
                  //TDS参数
                  delete this.buildDetails[i].tProcess;
                  delete this.buildDetails[i].tdsProcess;
                  delete this.buildDetails[i].tPreCoef;
                  delete this.buildDetails[i].tdsPreCoef;
                  //rf参数
                  delete this.buildDetails[i].rfBandMath;
                  delete this.buildDetails[i].tdsBandMath;
                  delete this.buildDetails[i].originFileName;
                  delete this.buildDetails[i].fileName;
               }else if(this.buildDetails[i].methodType === "Polynomial") {
                  delete this.buildDetails[i].BandFlag;
                  delete this.buildDetails[i].TdsFlag;
                  delete this.buildDetails[i].Poly_FFlag;
                  delete this.buildDetails[i].RFFlag;
                  delete this.buildDetails[i].SVRFlag;
                  //band 参数
                  delete this.buildDetails[i].bandCombineMath;
                  //TDS参数
                  delete this.buildDetails[i].tProcess;
                  delete this.buildDetails[i].tdsProcess;
                  delete this.buildDetails[i].tPreCoef;
                  delete this.buildDetails[i].tdsPreCoef;
                  //rf参数
                  delete this.buildDetails[i].rfBandMath;
                  delete this.buildDetails[i].tdsBandMath;
                  delete this.buildDetails[i].originFileName;
                  delete this.buildDetails[i].fileName;
               }else if(this.buildDetails[i].methodType === "TAndTds") {
                  delete this.buildDetails[i].BandFlag;
                  delete this.buildDetails[i].PolyFlag;
                  delete this.buildDetails[i].Poly_FFlag;
                  delete this.buildDetails[i].RFFlag;
                  delete this.buildDetails[i].SVRFlag;
                  //band 参数
                  delete this.buildDetails[i].bandCombineMath;
                  //polynomial参数
                  delete this.buildDetails[i].polynomialBandMath;
                  //rf参数
                  delete this.buildDetails[i].rfBandMath;
                  delete this.buildDetails[i].originFileName;
                  delete this.buildDetails[i].fileName;
               }else if(this.buildDetails[i].methodType === "PolyF") {
                  delete this.buildDetails[i].BandFlag;
                  delete this.buildDetails[i].PolyFlag;
                  delete this.buildDetails[i].TdsFlag;
                  delete this.buildDetails[i].RFFlag;
                  delete this.buildDetails[i].SVRFlag;
                  //band 参数
                  delete this.buildDetails[i].bandCombineMath;
                  //polynomial参数
                  delete this.buildDetails[i].polynomialBandMath;
                  //rf参数
                  delete this.buildDetails[i].rfBandMath;
                  delete this.buildDetails[i].originFileName;
                  delete this.buildDetails[i].fileName;
               }else if(this.buildDetails[i].methodType === "RTrees") {
                  delete this.buildDetails[i].BandFlag;
                  delete this.buildDetails[i].PolyFlag;
                  delete this.buildDetails[i].TdsFlag;
                  delete this.buildDetails[i].Poly_FFlag;
                  delete this.buildDetails[i].SVRFlag;
                  //band 参数
                  delete this.buildDetails[i].bandCombineMath;
                  //polynomial参数
                  delete this.buildDetails[i].polynomialBandMath;
                  //TDS参数
                  delete this.buildDetails[i].tProcess;
                  delete this.buildDetails[i].tdsProcess;
                  delete this.buildDetails[i].tPreCoef;
                  delete this.buildDetails[i].tdsPreCoef;
                  delete this.buildDetails[i].tdsBandMath;
               }else if(this.buildDetails[i].methodType === "Svr") {
                  delete this.buildDetails[i].BandFlag;
                  delete this.buildDetails[i].PolyFlag;
                  delete this.buildDetails[i].TdsFlag;
                  delete this.buildDetails[i].Poly_FFlag;
                  delete this.buildDetails[i].RFFlag;
                  //band 参数
                  delete this.buildDetails[i].bandCombineMath;
                  //polynomial参数
                  delete this.buildDetails[i].polynomialBandMath;
                  //rf参数
                  delete this.buildDetails[i].rfBandMath;
                  //TDS参数
                  delete this.buildDetails[i].tdsBandMath;
               }
            }
          }
         
          manualParam.model = this.buildDetails;
          console.log( manualParam.model)
          if (this.modelData.remark == "") {
            manualParam.remark =
              this.username + "-" + utils.formatDate("MM-dd hh:mm:ss", new Date());
          } else {
            manualParam.remark = this.modelData.remark;
          }
          manualParam.username = this.username;
          this.newModelDialog = false;
          if (this.lastModelId != "") {
            //模型迭代时 需要lastModelId
            manualParam.lastModelId = this.lastModelId;
            manualParam.waterParameters = this.lastModelwaterParameters;
          } else {
            manualParam.waterParameters = this.paramTabList;
          }
          // console.log(manualParam)
          //调接口 接口调成功后清空
          this.$fetch({
            url: process.env.PROGOO_GATE_WATER + "model/manualCreated",
            method: "post",
            data: manualParam,
          }).then((res) => {
            if (res.data.code === 200) {
              this.$refs.dataConfigureTable.formDataInit(true);
              this.modelData.equipmentId = "";
              this.cancelConfigure();
            }
          });
        } else {
          this.$notify.error({
            title: "失败",
            message: "请输入完整内容",
          });
        }
      });
    },
    cancelConfigure() {
      this.newModelDialog = false;
      this.PolynomialFlag = false;
      this.RandomFlag = false;
      this.BandFlag = false;
      this.TdsFlag = false;
      this.lastModelId = "";
      this.tip_originFileName = "";
      this.paramChooseItem = 0;
      this.modelData = {
        id: "",
        equipmentId: "",
        equipmentName: "",
        waterParameters: "",
        methodType: "",
        remark: "",
      };
      this.paramTabList = [];
      this.buildDetails = [];
      this.isSel_wave = false;
      this.isTPreCoef = false;
      this.isTdsPreCoef = false
    },
    importCancel() {
      this.importForm.equipmentId = "";
      this.importDialogFlag = false;
    },
    calibrationClick(tab, event) {
      //模型校准获取模型的原始数据列表
      this.tabIndex = tab.index;
      let currentParam = tab.$vnode.data.key;
      let param = {};
      param.equipmentId = this.calibrationForm.equipmentId;
      param.paramKey = currentParam;
      param.dateStart = this.calibrationForm.dateStart;
      param.dateEnd = this.calibrationForm.dateEnd;
      if (this.calibrationForm.equipmentId == "" || this.calibrationForm.time == "") {
        this.$notify.error({
          title: "",
          message: "请先选择设备和时间",
        });  
      } else {
        this.timeList.length = 0;
        this.dataEntryList.length = 0;
        this.resultValueList.length = 0;
        this.$fetch({
          url: process.env.PROGOO_GATE_WATER + "model/calibrationPreview", //TODO程澳提供接口
          method: "post",
          data: param,
        }).then((res) => {
          if (res.data.code === 200) {
            let tempList = res.data.result;
            let tempEntryList = []
            for (let i in tempList) {
              this.timeList.push(tempList[i].saveTime);
              this.resultValueList.push(tempList[i].paramvalue);
              tempEntryList.push(JSON.parse(tempList[i].paramJson))
            }
            for(let i in tempEntryList){
              this.dataEntryList.push(tempEntryList[i][currentParam])
            }
          }
        });
      }
    },
    calibrationFinish() {
      //模型校准方法
      let param = {};
      param.dateEnd = this.calibrationForm.dateEnd;
      param.dateStart = this.calibrationForm.dateStart;
      param.equipmentId = this.calibrationForm.equipmentId;
      param.paramKeyList = this.calibrationForm.params;
      param.modelTempId = this.calibrationForm.modelTempId;
      param.remark = this.calibrationForm.remark;
      this.$fetch({
          url: process.env.PROGOO_GATE_WATER + "model/calibration", //TODO程澳提供接口
          method: "post",
          data: param,
        }).then((res) => {
          if (res.data.code === 200) {
            this.clearCaliInput()
            this.calibrationFlag = false;
            this.$notify.success({
              title: "成功",
              message: "模型校准成功",
            });
          }
        });
      
    },
    calibrationFormClose() {
      this.clearCaliInput()
      this.calibrationFlag = false;
    },
    clearCaliInput(){
      //清空校准表单
      this.calibrationForm = {
        equipmentId: "",
        params: [],
        time: "",
        dateStart: "",
        dateEnd: "",
        remark: "",
      }
      this.timeList = [];
      this.dataEntryList = [];
      this.resultValueList = [];
      this.buildDetails = [];
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less">
.dataComfigure {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 15px;
  overflow-y: scroll;
  .dataConfigure_table {
    width: 100%;
    overflow-y: unset;
  }
  .dataConfigure_searchForm {
    width: 100%;
    float: left;
  }
  .dataConfigure_searchFormItem {
    float: left;
  }
  .randomTable {
    width: 100%;
    .randomTableTitle {
      display: flex;
      .randomTableTitleItem {
        width: 200px;
        margin: 0 10px;
      }
    }
    .randomTableData {
      display: flex;
      width: 100%;
      margin: 10px 0;
      .randomInputForm {
        width: 100%;
        .el-form-item__content {
          margin-left: 15% !important;
          display: flex;
          .el-input {
            width: 200px;
            margin: 0 10px;
          }
        }
        .randomInputFormContent {
          margin-left: 0 !important;
          .randomInputItem {
            width: 40%;
            display: flex;
          }
        }
      }
    }
  }
  .bandTable {
    width: 100%;
    display: flex;
    flex-direction: column;

    .bandTableItem {
      display: flex;
      width: 100%;
      flex-direction: row;
      margin: 10px 0;
      .bandTableItem_conLabel {
        width: 12%;
        text-align: center;
        background: #4595e6;
        color: #fff;
        display: flex;
        justify-content: center;
        align-items: center;
      }
      .bandTableItem_con {
        width: 88%;
        display: flex;
        flex-direction: column;
        border: 1px solid #ced0d4;
        .bandTableItem_input {
          display: flex;
          margin: 20px 3%;
          flex-direction: row;
          width: 94%;
          .bandTableItem_inputItem {
            display: flex;
            margin-right: 10px;
            width: 40%;
          }
          .el-form-item__content {
            margin-left: 10px !important;
            display: flex;
            align-items: center;
            width: 100%;
          }
          .el-form-item__label {
            text-align: left !important;
          }
        }
      }
      .bandTableItem_conBand {
        width: 88%;
        display: flex;
        border: 1px solid #ced0d4;
        box-sizing: border-box;
        flex-direction: column;
        padding: 20px 3%;
        .bandTableItem_conBand_con {
          width: 100%;
          display: flex;
          flex-direction: column;
          flex-wrap: wrap;
          .bandTableItem_conBandItemLeft {
            flex: 1;
            width: 100%;
            margin-bottom: 10px;
            display: flex;
            .el-form-item {
              width: 100%;
              display: flex;
              .el-form-item__label {
                text-align: left !important;
              }
              .el-form-item__content {
                margin-left: 10px !important;
                display: flex;
                align-items: center;
                width: 100%;
              }
            }
          }
          .bandTableItem_conBandItemRight {
            flex: 2;
            width: 100%;
            display: flex;
            margin-bottom: 10px;
            .el-form-item {
              width: 47%;
              margin-right: 3%;
              display: flex;
              .el-form-item__label {
                text-align: left !important;
              }
              .el-form-item__content {
                display: flex;
                margin-left: 0 !important;
                align-items: center;
                width: 80%;
              }
            }
          }
        }
        .bandTableItem_conBandItem {
          display: flex;
          flex-wrap: wrap;
          width: 100%;
          .bandTableItem_conBandItem_tds {
            display: flex;
            flex-direction: row;
            align-items: center;
            .el-form-item {
              width: 100%;
              margin: 0 3% 10px 0;
              display: flex;
              .el-form-item__label {
                text-align: left !important;
              }
              .el-form-item__content {
                display: flex;
                margin-left: 0 !important;
                align-items: center;
                width: 80%;
              }
            }
          }
          .bandTableItem_conBandItem_rf {
            display: flex;
            flex-direction: row;
            align-items: center;
            .el-form-item {
              width: 100%;
              margin: 0 3% 10px 0;
              display: flex;
              .el-form-item__label {
                text-align: left !important;
              }
              .el-form-item__content {
                display: flex;
                margin-left: 0 !important;
                align-items: center;
                width: 80%;
              }
            }
          }
          .bandTableItem_tips {
            margin: 5px 0;
            color: #b2b2b2;
          }
        }
      }
    }
    .bandTableTitle {
      width: 100%;
      display: flex;
      flex-direction: row;
      color: #409eff;
      .bandTableTitleItem {
        width: 33%;
        text-align: center;
        border: 1px solid #ccc;
        line-height: 35px;
        height: 35px;
      }
    }
    .bandTableDataBg {
      width: 100%;
      display: flex;
      flex-direction: row;

      .bandTableData {
        width: 33%;
        display: flex;
        border: 1px solid #ccc;

        flex-direction: column;
        .bandTableDataItem {
          width: 100%;
          text-align: center;
          border-top: 1px solid #ccc;
          line-height: 35px;
          height: 35px;
        }
      }
    }
  }
  .testResultForm {
    width: 100%;
    display: flex;
    flex-direction: row;
    margin-top: 20px;
    height: 35px;
    line-height: 35px;
    .testResultFormItem {
      width: 25%;
      text-align: center;
    }
  }
  .testResultFormCol {
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    line-height: 35px;
    border: 1px solid #b2b2b2;
    .testResultFormColItem {
      width: 100%;

      display: flex;
      flex-direction: row;
      .testResultFormItem {
        width: 25%;
        height: 30px;
        text-align: center;
      }
    }
  }
  .testFormClass {
    width: 90%;
    margin: 0 5%;
    .el-form-item {
      .el-form-item__label {
        text-align: left !important;
      }
    }
  }
  .exportForm {
    width: 80%;
    margin: 0 10%;
    display: flex;
    flex-direction: column;
    height: 150px;
    .el-form-item {
      .el-form-item__label {
        text-align: left !important;
      }
    }
  }
}
</style>
